package dk.flashnotes.fffExample.text {
	import flash.text.TextFieldAutoSize;	
	import flash.text.AntiAliasType;	
	import flash.text.TextField;	
	import flash.display.Sprite;

	/**
	 * @author Josef Kj�rgaard
	 */
	public class Label extends Sprite {

		private var _tf : TextField;
		private var _sText : String;
		private var _nSize : Number;
		private var _nAlpha : Number;

		public function Label(sText : String, nSize : Number = 16, nAlpha : Number = 1) {
			
			_nAlpha = nAlpha;
			_nSize = nSize;
			_sText = sText;
			
			createElements();
			initLabel();
		}

		private function initLabel() : void {
			sText = _sText;
			alpha = _nAlpha;
		}

		public function set sText(oNewValue : String) : void {
			_sText = oNewValue; 
			_tf.htmlText = '<font size="' + _nSize + '">'+_sText+'</font>';
		}

		private function createElements() : void {
			_tf = new TextField();
			addChild(_tf);
			
			_tf.embedFonts = true;
			_tf.antiAliasType = AntiAliasType.ADVANCED;
			
			_tf.selectable=false;
			
			_tf.autoSize = TextFieldAutoSize.LEFT;
			
			_tf.defaultTextFormat = ETextFormats.tforBASIC;
		}				public function get tf() : TextField {
			return _tf;		}
	}
}
